<template>
	<view class="container">
		<view class="header uni-flex uni-row flex-between  header-nav">
			<uni-nav-bar title="预警提醒">
				<template slot='left'  >
					<view class="flex width-100">
						<i class='iconfont iconfanhui' link @click='Back()'></i>
					</view>
				</template>
			</uni-nav-bar>
		</view>
		<view class="position-r-top" v-if="remindList.length">
			<view class="remind">
				<view class="">
					<uni-list-item v-for="item in remindList"
					               :key="item.logId" 
								   :title="item.sendFlag || ' '" 
								   :note="item.content || ' '"
								    class="remind-list"
									link
									@click="readMessage(item)">
									<view class="right-badge" slot="footer">
										<view class="margin-r-5">{{item.createTime}}</view>
										<view :class="{'badge-l':item.status == 0,'border-r50':item.status == 0}" class="scale-6">
										</view>
									</view>
					</uni-list-item>
				</view>
			</view>
			<view v-show="showLoading">
				<uni-load-more :status="loadStatus"></uni-load-more>
			</view>
		</view>
		<view v-else class="nodata">
			<text>暂无消息</text>
		</view>
	</view>
</template>
<script>
	import {remindWarning,remindWarningStatus} from '@/common/api/profile.js'
	export default {
		data() {
			return {
				remindList:[],
				page:1,
				size:20,
				showLoading:false,
				loadStatus:'loading'
			}
		},
		onLoad() {
			this.getRemindList();
			// uni.startPullDownRefresh();
		},
		onReachBottom(){//到底加载
			console.log(111)
			// if(this.remindList.length < this.page * this.size) return this.showLoading =true;
			// 	this.page+=1;
			// 	this.getRemindList();
			if(!this.showLoading){
				this.showLoading = true;
				this.page+=1;
				this.getRemindList();
			}
		},
		onPullDownRefresh() {//下拉刷新
			setTimeout( () => {
				this.page = 1;
				this.remindList = [];
				this.showLoading=false;
				this.getRemindList();
			    uni.stopPullDownRefresh();
				console.log('success')
			        }, 1000);
		},
		methods: {
			getRemindList(){
				remindWarning(this.page,this.size).then( res => {
					if(res.code === "20000"){
						this.isLoadMore=false;
						this.remindList = this.remindList.concat(res.data.records);
						if(res.data.records.length < this.size){  //判断接口返回数据量小于请求数据量，则表示此为最后一页
							  this.showLoading=true;                                             
							  this.loadStatus='nomore';
						}else{
							  this.showLoading=false;
						}
					}
				})
			},
			readMessage(data){
				uni.navigateTo({
					url:'/pages/Personal/RemindWarning/RemindWarningDetail/RemindWarningDetail?detailData=' + JSON.stringify(data)
				})
			},
			Back(){
				uni.switchTab({
					url:'/pages/Personal/Personal'
				})
			}
		}
	}
</script>
<style>
.container{background-color: #eee;}
.remind-list{height: 70px;}
.remind-list /deep/ .uni-badge {margin-left: 10px!important;transform: scale(0.5,0.5);color: transparent;}
.remind-list  /deep/ .uni-list-item__content-note,.remind-list /deep/ .uni-list-item__content-title{text-overflow: ellipsis;white-space: nowrap;}
.remind-list /deep/ .uni-list-item__content-title{font-weight: bold;}
</style>
